package com.javatest.demo.service;

import com.javatest.demo.dao.StudentDao;
import com.javatest.demo.dao.StudentDao2;
import com.javatest.demo.entities.Student;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author liuziyang
 * @create 2020-06-20 12:20
 */
@Service
public class DbService {

    @Autowired
    private StudentDao studentDao;

    @Autowired
    private StudentDao2 studentDao2;

    @PostConstruct
    private void init() {
        studentDao.initDb();
        studentDao2.initDb();
    }

    public List<Student> getAllStudent() {
        return studentDao.queryAllStudent();
    }

    public void addNewStudent(Student student) {
        studentDao.insert(student);
    }
}
